public class test6 {
    //牛客 KS32 找缺失的数字
    public static void main(String[] args) {
        int[] arr = {0,1,2,3,4,5,6,7,8,9};
        System.out.println(find(arr));
    }

    public static int find(int[] arr){
        int left = 0,right = arr.length-1,mid = 0;
        while (left<right){
            mid = left + (right-left)/2;
            if(arr[mid]==mid){
                left = mid + 1;
            }else{
                right = mid;
            }
        }
        //一定要注意
        if(arr[left]==left){
            return left+1;
        }
        return left;
    }
}
